package models

import (
	"gorm.io/gorm"
	"member/member-srv/basic/config"
)

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(35);comment:'账号'"`
	Password string `gorm:"type:varchar(32);comment:'密码'"`
}
type MemberPlan struct {
	gorm.Model
	PlanName  string `gorm:"type:varchar(35);comment:'会员套餐名称'"`
	PlanPrice string `gorm:"type:varchar(35);comment:'会员套餐'"`
	Day       string `gorm:"type:varchar(35);comment:'到期时间'"`
}
type Order struct {
	gorm.Model
	UserId       int    `json:"user_id"`
	MemberPlanId int    `json:"member_plan_id"`
	Name         string `gorm:"type:varchar(35);comment:'名称'"`
	Price        string `gorm:"type:varchar(20);comment:'价格'"`
	Number       string `gorm:"type:varchar(35);comment:'订单标号'"`
}

func MemberPlanAdd[T any](data *T) error {
	return config.DB.Create(&data).Error
}
func MemberPlanList[T any](data *T, id int) error {
	return config.DB.Where("id=?", id).Find(&data).Error
}

func OrderAdd[T any](data *T) error {
	return config.DB.Create(&data).Error
}

func OrderList[T any](data *T, id int) error {
	return config.DB.Where("id=?", id).Find(&data).Error
}
